<style type="text/css">

   table,tr,th,td {
        border: 1px solid #f4f4f4;
   }
   .table {
    /*padding: 0 6.5%;*/
 /*   display: flex;
    flex-flow: row;
    align-items: center;*/
   }
   .table>table {
    width: 100%;
   }
   .table th,.table tr,.table td {
    text-align: center;
   }
   .table th,.table td {
    padding: 10px 0;
   }
   .table td {
    background-color: #f5f5f5;
   }
   .inp>td>input {
    width: 60%;
    border: none;
    outline: none;
    background: transparent;
    text-align: center;
   }
   .inp>td {
    text-align: center;
   }
   .button>button{
    width: 80px;
    background-color: red;
    color: #fff;
    text-align: center;
    padding: 10px;
    border-radius: 5px;
   }
   .time {
    width: 15%;
   }
   .set {
    background:#fff;
    color:#5fb878;
   }
   .set>input {
    width: 100% !important;
    max-width: 100px;
    border: 1px solid #e8e6e6 !important;
   }
   .mr {
    width: 7%;
   }
   .button>button {
    outline: none;
    border: none;
   }
   .inp>td:nth-child(1) {
    width: 5%;
   }

   .form-group {
    margin: 20px auto !important;

   }
   .loadNewPage {
    width: 80px;
    padding: 1px 5px;
    font-size: 11px;
    line-height: 1.5;
    border-radius: 2px;
    color: #fff;
    background-color: #2c3e50;
    cursor: pointer;
   }


</style>
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">开始时间:</label>
        <div class="col-xs-12 col-sm-8">

            <div class="layui-inline">
        
              <div class="layui-input-inline">
                <input type="text" class="layui-input" id="start" value="{$group_info.start_time|date = 'Y-m-d H:i:s',###}" placeholder="yyyy-MM-dd HH:mm:ss">
     
</div>
  </div>
            
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">结束时间:</label>
        <div class="col-xs-12 col-sm-8">
            <div class="layui-inline">
        
                <div class="layui-input-inline">
                    <input type="text" class="laydate-icon layui-input" value="{$group_info.end_time|date = 'Y-m-d H:i:s',###}" id="end" placeholder="yyyy-MM-dd HH:mm:ss">
                </div>
            </div>

        </div>
    </div>
    
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">选择商品:</label>
        <p type="button" id="jumpNewPage" class="btn btn-xs btn-primary btn-dialog">选择</p>
    </div>
 <!--    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">限购数量</label>
        <div class="col-xs-12 col-sm-8">
                        
          <input id="c-sort" class="form-control" name="" type="number" value="">

        </div>
    </div> -->
    <div class="form-group table" style="">
        <table border="0" class="Table">
            <tr>
                <th>ID</th>
                <th>商品名称</th>
                <th>商品图片</th>
                <th>添加时间</th>
                <th>更新时间</th>
                <th>选规格</th>
                <th>操作</th>
            </tr>
            {volist name="group_all_info" id="vo"}
                <tr class='inp'>
                    <td>{$vo.id}</td>
                    <td >{$vo.title|mb_substr=0,15,'utf-8'}...</td>
                    <td><image src='{$vo.image}' style="width:20% !important;"></td>
                    <td class="time">{$vo.start_time|date = 'Y-m-d H:i:s',###}</td>
                    <td class="time">{$vo.update_time|date = 'Y-m-d H:i:s',###}</td>
                    <td class="button">
                      <p style='background-color: #2c3e50;' class="selectNewPage btn btn-xs btn-primary btn-dialog">选规格</p>
                    </td>
                    <td class="button">
                      <button onclick="del({$vo.id})">删除</button>
                    </td>
                </tr>
            {/volist} 
        </table>
    </div>
    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-success btn-embossed" id='submit_form'>确认</button>
            
        </div>
    </div>
    <input type="hidden" id="url" name="" value="{:url('activity/group_detail/details',['group_id'=>$group_info.id])}">
    <input type="hidden" id="load_url" name="" value="{:url('activity/group_detail/other',['group_id'=>$group_info.id])}">
</form>
<script type="text/javascript" src="/assets/layui/layui.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<!-- <script type="text/javascript" src="/public/assets/laydate/laydate.js"></script> -->
<link href="/assets/layui/css/layui.css"/>
<script type="text/javascript">


    
    window.onload = function (argument) {
        layui.use(['laydate','layer'], function(){
        var laydate = layui.laydate;
          var layer = layui.layer;
            //日期时间选择器
              laydate.render({
                elem: '#start'
                ,type: 'datetime'
                ,theme: '#393D49'
                ,done: function(value, date, endDate){
                    console.log(value) //得到日期生成的值，如：2017-08-18
                },
                ready:function(){
                    $('.laydate-prev-y').text('<<');
                    $('.laydate-prev-m').text('<');
                    $('.laydate-next-m').text('>');
                     $('.laydate-next-y').text('>>');
                }
              });
              laydate.render({
                elem: '#end'
                ,type: 'datetime'
                ,done: function(value, date, endDate){
                    console.log(value) //得到日期生成的值，如：2017-08-18
                },
                ready:function(){
                    $('.laydate-prev-y').text('<<');
                    $('.laydate-prev-m').text('<');
                    $('.laydate-next-m').text('>');
                     $('.laydate-next-y').text('>>');
                }
              });

        document.getElementById('jumpNewPage').onclick = function (e) {
            var url = document.getElementById('url').value;

            var op = layer.open({
                title:'拼团产品',
                type:2,
                content: url,
                maxmin: true,
                area: ['80%', '80%'],
                success:function(){

                    var timer = setInterval(function(){
                        var status = sessionStorage.getItem('status');
                        
                        if (status == '1') {
                            sessionStorage.clear();
                              layer.close(op);
                              window.location.reload();
                            clearInterval('timer');

                          
                        }
                    },200)
                }
            })
        
        }
        //新增选规格弹窗页面
        $(".selectNewPage").click(function (e) {
            var gg_id = $(this).parents('tr').children("td").eq(0).text();
            // alert(gg_id)
            var url = '{:url("activity/group_detail/select_sku")}?gg_id='+ gg_id;
            var op = layer.open({
                title:'选择商品规格',
                type:2,
                content: url,
                maxmin: true,
                area: ['90%', '90%'],
                success:function(){

                    var timer = setInterval(function(){
                        var status = sessionStorage.getItem('status');
                        
                        if (status == '1') {
                            sessionStorage.clear();
                              layer.close(op);
                              window.location.reload();
                            clearInterval('timer');

                          
                        }
                    },200)
                }
            })
        
        })
    });
}

  function del(id){
      var id = id;
      var url_ = "{:url('activity/group_detail/delete')}";
      $.ajax({
        type:'post',
        url:url_,
        data:{id:id},
        dataType:"json",
        success:function(msg){
          if(msg.state == 1){
              layer.msg('删除成功！');
          }else{
              layer.msg('删除失败！');
          }
        }
      })

    }   
    
             
        
    
</script>
